package com.feicheng.lanniao.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.feicheng.lanniao.entity.CarBuyClientVo;
import com.feicheng.lanniao.entity.CarBuyInfo;
import com.feicheng.lanniao.result.ResultInfo;
import com.feicheng.lanniao.service.ICarBuyClientVoService;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author feichengTech
 * @since 2021-09-07
 */
@RestController
@RequestMapping("/lanniao-admin/car-buy-client-vo")
public class CarBuyClientVoController {
	@Autowired
	ICarBuyClientVoService ICarBuyClientVoService;
	/**
	 * 查询所有买车信息
	 * @param title 标题
	 * @param details 详情
	 * @param clientId  用户ID
	 * @param currentPage 当前页
	 * @param pageSize 每页分多少条
	 * @return 买车信息集合
	 */
	@GetMapping("/page")
	public ResultInfo buyCarList(
			String title,
			String details,
			Integer clientId ,
			@RequestParam(required = false, defaultValue = "1") Integer currentPage, 
			@RequestParam(required = false, defaultValue = "10") Integer pageSize) {
		
		return ICarBuyClientVoService.getCarBuyClientVoList(title,details, clientId, currentPage, pageSize);
		
	}
	/**
	 * 查询1条买车信息
	 * @param cbId 买车信息ID
	 * @return 买车对象
	 */
	@GetMapping("/info")
	public ResultInfo getOneCb(Integer cbId) {
		return ICarBuyClientVoService.getOneCarBuyInfo(cbId);
	}
	/**
	 * 修改买车信息
	 * @param carBuyInfo 对象
	 * @return Boolean值
	 */
	@PutMapping("/info")
	public ResultInfo editCb(CarBuyInfo carBuyInfo) {
		return ICarBuyClientVoService.editOneCarBuyInfo(carBuyInfo);
	}
	/**
	 * 增加买车信息
	 * @param title 买车标题
	 * @param details 买车描述
	 * @param clientId 用户ID
	 * @param tel 发布人电话
	 * @param wxNumber 发布人微信
	 * @return Boolean值
	 */
	@PostMapping("/info")
	public ResultInfo saveOneCb(String tel,String wxNumber,String title,String details,Integer clientId) {
		return ICarBuyClientVoService.insertOneCarInfo(tel,wxNumber,title,details,clientId);
	}
}

